import { Entity, PrimaryGeneratedColumn, ManyToOne, Column, JoinColumn } from 'typeorm';
import { Role } from './role.entity';
import { Menu } from './menu.entity';

/**
 * 角色菜单关联表
 */
@Entity('sys_menu_role')
export class MenuRole {
  /**
   * 角色菜单关联表ID
   */
  @PrimaryGeneratedColumn({ comment: '角色菜单关联表ID' })
  menuRoleId: number;

  /**
   * 角色ID
   */
  @ManyToOne(() => Role, (role) => role.roleMenus)
  @JoinColumn({ name: 'roleId' })
  role: Role;

  /**
   * 菜单ID
   */
  @ManyToOne(() => Menu, (menu) => menu.menuRoles)
  @JoinColumn({ name: 'menuId' })
  menu: Menu;
}
